package com.edou.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.system.dao.ISysEmailDao;
import com.edou.system.dto.SysEmailCondition;
import com.edou.system.entity.SysEmail;
import com.edou.system.service.ISysEmailService;

@Service("sysEmailServiceImpl")
@Transactional(value = "transactionManager")
public class SysEmailServiceImpl implements ISysEmailService {

	@Resource(name="sysEmailDaoImpl")

	private ISysEmailDao sysEmailDao;
	
	
	
	/**
	 * 保存Email信息
	 * 
	 * @param email
	 *            邮件实体
	 */
	@Override
	public void add(SysEmail email) {
		// TODO Auto-generated method stub
		sysEmailDao.add(email);
	}

	@Override
	public List<SysEmail> listTenNoSendMail() {
		// TODO Auto-generated method stub
		return sysEmailDao.listTenNoSendMail();
	}

	@Override
	public void updateEmailState(String id, Integer state) {
		// TODO Auto-generated method stub
		sysEmailDao.updateEmailState(id, state);
	}

	/**
	 * 查询区间数据
	 * @param bounds
	 * @param condition
	 * @return
	 */
	
	@Override
	public void listSysEmailByPage(PageResult<SysEmail> pageResult,SysEmailCondition condition) {
		int rows = sysEmailDao.listSysEmailByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<SysEmail> list = sysEmailDao.listSysEmailByPage(rowBounds, condition);
		pageResult.setResult(list);
	}

	@Override
	public void delByIds(String[] ids) {
		// TODO Auto-generated method stub
		sysEmailDao.delByIds(ids);
	}



}
